package com.wbl.train.member.controller;

import com.wbl.train.common.context.LoginMemberContext;
import com.wbl.train.common.member.dto.TicketDto;
import com.wbl.train.common.member.entity.TicketEntity;
import com.wbl.train.common.page.PageVo;
import com.wbl.train.common.result.R;
import com.wbl.train.member.service.TicketService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 王博纶
 * @since 2024-03-07
 * @description 车票
 */
@Slf4j
@RestController
@RequestMapping("/ticket")
@Tag(name = "车票控制器类",
        description = "TicketController 车票 后端数据接口")
public class TicketController {
    @Autowired
    private TicketService ticketService;


    /**
     * 通过id查询 车票
     * @param ticketDto ticketDto
     * @return Result
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/query")
    public R<PageVo<TicketEntity>> getById(TicketDto ticketDto) {
        // 车票查询
        log.debug("ticketDto :{}",ticketDto);
        ticketDto.setMemberId(LoginMemberContext.getId());
        PageVo<TicketEntity> pageVo = ticketService.queryTicket(ticketDto);
        return R.ok("查询成功",pageVo);
    }
}
